package com.eephone.ep.configs;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 设置App是否首次运行的配置检查
 * Created by xyf on 2015/12/16.
 */
public class ConfigFirstRun {

    private static final String FIRST_RUN = "FIRST_RUN_EEPHONE";

    /**
     * 检查是否第一次运行
     *
     * @param context
     * @return
     */
    public static boolean isFirstRun(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(FIRST_RUN, Context.MODE_PRIVATE);
        int firstRun = preferences.getInt(FIRST_RUN, 0);
        if (firstRun == 0) {
            // FirstRun
            return true;
        } else {
            return false;
        }
    }

    /**
     * 设置已经完成了配置
     * 下一次不会提示第一次运行
     *
     * @param context
     */
    public static void setHasRun(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(FIRST_RUN, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt(FIRST_RUN, 1);
        editor.commit();
    }

}
